﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Ray : MonoBehaviour
{
    public Levels level;
    public string content= "关系线破裂了！~游戏结束~";
    public GameObject Another;
    private void Start()
    {
        Updates = Raycast;
    }
    private void FixedUpdate()
    {
        Updates();
    }

    private delegate void zero();
    zero Updates;
    void Raycast()
    {
        RaycastHit2D hit2D = Physics2D.Raycast(transform.position, Another.transform.position - transform.position,Mathf.Infinity,1);
        if (hit2D.rigidbody.gameObject != Another)
        {
            Updates = null;
            level.OnHit(content);
        }
    }
}
